#ifndef __GAME_TAGS__
#define __GAME_TAGS__

typedef struct tagTEXTUREITEMSTRUCT
{
    LPWSTR						m_pstrFileName;   
    LPDIRECT3DTEXTURE9			m_pd3dTexture;    
} TEXTUREITEMSTRUCT;

typedef struct tagATTRIBUTEITEMSTRUCT
{
    int							m_nTexture;
    int							m_nMaterial;
} ATTRIBUTEITEMSTRUCT;

typedef struct tagBOUNDINGCUBE
{
    D3DXVECTOR3					m_vMinimum;
    D3DXVECTOR3					m_vMaximum;

	tagBOUNDINGCUBE() { m_vMinimum = D3DXVECTOR3(+FLT_MAX, +FLT_MAX, +FLT_MAX); m_vMaximum = D3DXVECTOR3(-FLT_MAX, -FLT_MAX, -FLT_MAX); };
	tagBOUNDINGCUBE(D3DXVECTOR3 vMinimum, D3DXVECTOR3 vMaximum) { m_vMinimum = vMinimum; m_vMaximum = vMaximum; }

	void Union(D3DXVECTOR3& vMinimum, D3DXVECTOR3& vMaximum) {
		if (vMinimum.x < m_vMinimum.x) m_vMinimum.x = vMinimum.x;
		if (vMinimum.y < m_vMinimum.y) m_vMinimum.y = vMinimum.y;
		if (vMinimum.z < m_vMinimum.z) m_vMinimum.z = vMinimum.z;
		if (vMaximum.x > m_vMaximum.x) m_vMaximum.x = vMaximum.x;
		if (vMaximum.y > m_vMaximum.y) m_vMaximum.y = vMaximum.y;
		if (vMaximum.z > m_vMaximum.z) m_vMaximum.z = vMaximum.z;
	}
	void Transform(D3DXMATRIX *pmtxTransform) {
		D3DXVECTOR3 vVertices[8];
		vVertices[0] = D3DXVECTOR3(m_vMinimum.x, m_vMinimum.y, m_vMinimum.z);
		vVertices[1] = D3DXVECTOR3(m_vMinimum.x, m_vMinimum.y, m_vMaximum.z);
		vVertices[2] = D3DXVECTOR3(m_vMaximum.x, m_vMinimum.y, m_vMaximum.z);
		vVertices[3] = D3DXVECTOR3(m_vMaximum.x, m_vMinimum.y, m_vMinimum.z);
		vVertices[4] = D3DXVECTOR3(m_vMinimum.x, m_vMaximum.y, m_vMinimum.z);
		vVertices[5] = D3DXVECTOR3(m_vMinimum.x, m_vMaximum.y, m_vMaximum.z);
		vVertices[6] = D3DXVECTOR3(m_vMaximum.x, m_vMaximum.y, m_vMaximum.z);
		vVertices[7] = D3DXVECTOR3(m_vMaximum.x, m_vMaximum.y, m_vMinimum.z);
		for (int i = 0; i < 8; i++) D3DXVec3TransformCoord(&vVertices[i], &vVertices[i], pmtxTransform);
		m_vMinimum = D3DXVECTOR3(+FLT_MAX, +FLT_MAX, +FLT_MAX);
		m_vMaximum = D3DXVECTOR3(-FLT_MAX, -FLT_MAX, -FLT_MAX);
		for (int i = 0; i < 8; i++) 
		{
			if (vVertices[i].x < m_vMinimum.x) m_vMinimum.x = vVertices[i].x;
			if (vVertices[i].y < m_vMinimum.y) m_vMinimum.y = vVertices[i].y;
			if (vVertices[i].z < m_vMinimum.z) m_vMinimum.z = vVertices[i].z;
			if (vVertices[i].x > m_vMaximum.x) m_vMaximum.x = vVertices[i].x;
			if (vVertices[i].y > m_vMaximum.y) m_vMaximum.y = vVertices[i].y;
			if (vVertices[i].z > m_vMaximum.z) m_vMaximum.z = vVertices[i].z;
		}
	}

	bool Intersect(tagBOUNDINGCUBE *pBoundingCube) {
		if (pBoundingCube->m_vMaximum.x < m_vMinimum.x) return(false);
		if (pBoundingCube->m_vMaximum.y < m_vMinimum.y) return(false);
		if (pBoundingCube->m_vMaximum.z < m_vMinimum.z) return(false);
		if (pBoundingCube->m_vMinimum.x > m_vMaximum.x) return(false);
		if (pBoundingCube->m_vMinimum.y > m_vMaximum.y) return(false);
		if (pBoundingCube->m_vMinimum.z > m_vMaximum.z) return(false);
		return(true);
	}

} BOUNDINGCUBE;







class CVertex
{
public:
    D3DXVECTOR3					m_vPosition; 

    CVertex(float x, float y, float z) { m_vPosition = D3DXVECTOR3(x, y, z); }
    CVertex(D3DXVECTOR3 vPosition) { m_vPosition = vPosition; }
    CVertex() { m_vPosition = D3DXVECTOR3(0.0f, 0.0f, 0.0f); }
};

class CDiffuseVertex
{
public:
    D3DXVECTOR3					m_vPosition;  
	DWORD						m_dwDiffuse;   

    CDiffuseVertex(float x, float y, float z, DWORD dwColor) { m_vPosition = D3DXVECTOR3(x, y, z); m_dwDiffuse = dwColor; }
    CDiffuseVertex() { m_vPosition = D3DXVECTOR3(0.0f, 0.0f, 0.0f); m_dwDiffuse = D3DCOLOR_XRGB(0, 0, 0xff); }
};

#define FVF_TEXTURE_1_SET		(D3DFVF_XYZ | D3DFVF_TEX1)

class CTexturedVertex
{
public:
    CTexturedVertex(float x, float y, float z, float u1, float v1) { m_vPosition = D3DXVECTOR3(x, y, z); m_vTexture1 = D3DXVECTOR2(u1, v1); }
    CTexturedVertex(D3DXVECTOR3 vPosition, D3DXVECTOR2 vTexture1) { m_vPosition = vPosition; m_vTexture1 = vTexture1; }
    CTexturedVertex() { m_vPosition = D3DXVECTOR3(0.0f, 0.0f, 0.0f); m_vTexture1 = D3DXVECTOR2(0.0f, 0.0f); }

    D3DXVECTOR3					m_vPosition;  
	D3DXVECTOR2					m_vTexture1;   
};

#define FVF_NORMAL_TEX2 (D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX2)
class CNormalTexture2 {
public:	
	D3DXVECTOR3		m_vPosition;
	D3DXVECTOR3		m_vNormal;
	D3DXVECTOR2		m_Tex1;
	D3DXVECTOR2		m_Tex2;	
};


#endif